package com.bw.device.adapter

import android.widget.TextView
import com.bw.device.R
import com.bw.device.entity.DeviceEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class DeviceAdapter:BaseQuickAdapter<DeviceEntity,BaseViewHolder>(R.layout.device_item) {
    override fun convert(holder: BaseViewHolder, item: DeviceEntity) {
        holder.setText(R.id.name,item.deviceName)
        holder.setText(R.id.state,item.status)
        holder.setText(R.id.position,item.installationLocation)
        holder.setText(R.id.type,item.deviceType)
        holder.setText(R.id.failure,"${item.failureRate*10}%")

        if(item.status=="故障"){
            val textView = holder.getView<TextView>(R.id.state)
            textView.setTextColor(0xF97316)
            textView.setBackgroundResource(R.drawable.search_background_gz)
        }
    }
}